//
//  ELHomeShowAddressView.m
//  ELProject
//
//  Created by Yuki on 2021/4/13.
//

#import "ElHomeTopView.h"
#import "ELSearchEnterView.h"///搜索框
@interface ElHomeTopView ()
/**  lb  **/
@property (nonatomic , strong)UILabel  *showAddressLb;
/**  搜索框  **/
@property (nonatomic , strong)ELSearchEnterView  *searchView;
@end
@implementation ElHomeTopView

#pragma mark - --------- 设置界面  ---------
- (void)_setupView{
    [super _setupView];
    
    self.backgroundColor = [UIColor colorWithRed:111.0/255.0 green:171.0/255.0 blue:240.0/255.0 alpha:1];
    
    /**  地址 图片 **/
    UIImageView *tipImgView = [UIImageView el_createImgViewWithImg:[UIImage imageNamed:@"home_showAddress"]];
    [self addSubview:tipImgView];
    [tipImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(30*Scale(), 30*Scale()));
        make.left.mas_equalTo(12*Scale());
        make.top.mas_equalTo(StateBarHeight() + 20*Scale());
    }];
    
    /**  地址  **/
    [self addSubview:self.showAddressLb];
    [self.showAddressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(tipImgView.mas_right).offset(5*Scale());
        make.centerY.mas_equalTo(tipImgView);
        make.height.mas_equalTo(20*Scale());
        make.right.mas_equalTo(-20*Scale());
    }];
    
    /**  搜索框  **/
    [self addSubview:self.searchView];
    [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12*Scale());
        make.height.mas_equalTo(36*Scale());
        make.top.mas_equalTo(NavgitionHeight() + 10*Scale());
        make.right.mas_equalTo(-40*Scale());
    }];
    
}
#pragma mark - --------- set方法  ---------
- (void)setFlexScale:(CGFloat)flexScale{
    _flexScale = flexScale;
    [self.searchView.superview layoutIfNeeded];
    [self.searchView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-(40+flexScale * 2)*Scale());
    }];
    
    [self.searchView.superview layoutIfNeeded];//强制绘制
}

#pragma mark - --------- lazy  ---------
/**  送至  **/
- (UILabel *)showAddressLb{
    if (!_showAddressLb) {
        _showAddressLb = [UILabel el_createLabelWithLabeltext:@"送至:" LabelFont:BoldFontWith(17, UIFontWeightMedium) LabeltextColor:ColorHex(0xffffff, 1)];
    }
    return _showAddressLb;
}

/**  搜索框  **/
- (ELSearchEnterView *)searchView{
    if (!_searchView) {
        _searchView = [[ELSearchEnterView alloc]init];
        _searchView.clipsToBounds = YES;
        _searchView.layer.cornerRadius = 18*Scale();
    }
    return _searchView;
}

@end
